home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / dev / c / cweb31p9d.lha / CWeb / ctangle.ch < prev    next >
Text File  |  1994-07-02  |  29KB  |  929 lines

  1.                                 -*-Web-*-
  2. This file, CTANGLE.CH, is part of CWEB.
  3. It is a changefile for CTANGLE.W, Version 3.1.
  4.  
  5. Authors and Contributors:
  6. (H2B) Hans-Hermann Bode, Universität Osnabrück,
  7.   (hhbode@@dosuni1.rz.uni-osnabrueck.de or HHBODE@@DOSUNI1.BITNET).
  8.  
  9. (KG) Klaus Guntermann, TH Darmstadt,
  10.   (guntermann@@iti.informatik.th-darmstadt.de).
  11.  
  12. (AS) Andreas Scherer,
  13.   Abt-Wolf-Straße 17, 96215 Lichtenfels, Germany.
  14.  
  15. (CS) Carsten Steger, Universität München,
  16.   carsten.steger@@informatik.tu-muenchen.de
  17.  
  18. (TW) Tomas Willis
  19.   tomas@@cae.wisc.edu
  20.  
  21. Caveat utilitor:  Some of the source code introduced by this change file is
  22. made conditional to the use of specific compilers on specific systems.
  23. This applies to places marked with `#ifdef __TURBOC__' and `#ifdef _AMIGA'.
  24.  
  25. This program is distributed WITHOUT ANY WARRANTY, express or implied.
  26.  
  27. The following copyright notice extends to this changefile only, not to
  28. the masterfile CTANGLE.W.
  29.  
  30. Copyright (C) 1993,1994 Andreas Scherer
  31. Copyright (C) 1991-1993 Hans-Hermann Bode
  32.  
  33. Permission is granted to make and distribute verbatim copies of this
  34. document provided that the copyright notice and this permission notice
  35. are preserved on all copies.
  36.  
  37. Permission is granted to copy and distribute modified versions of this
  38. document under the conditions for verbatim copying, provided that the
  39. entire resulting derived work is distributed under the terms of a
  40. permission notice identical to this one.
  41.  
  42. Version history:
  43.  
  44. Version    Date        Author    Comment
  45. a1/t1    10 Oct 1991    H2B    First attempt for CTANGLE.W 2.0.
  46. p2    13 Feb 1992    H2B    Updated for CTANGLE.W 2.2, ANSI and Turbo
  47.                 changefiles merged together.
  48. p3    16 Apr 1992    H2B    Updated for CTANGLE.W 2.4.
  49. p4    21 Jun 1992    H2B    Nothing changed.
  50. p5    18 Jul 1992    H2B    Extensions for C++ implemented.
  51. p5a    24 Jul 1992    KG    adaptions for other ANSI C compiler
  52. p5b    28 Jul 1992    H2B    Remaining headers converted to ANSI style.
  53. p6    06 Sep 1992    H2B    Updated for CTANGLE.W 2.7, |dot_dot_dot|
  54.                 added, parsing of @@'\'' fixed (due to KG),
  55.                 @@<Copy an ASCII constant@@> extended,
  56.                 (nonfatal) confusion in processing short
  57.                 comments fixed.
  58. p6a     15 Mar 1993     AS      Re-changing some of the TC stuff to SAS/C
  59. p6b     27 Jul 1993     AS      new patch level in accordance with CWeave
  60. p6c    04 Sep 1993    AS    new patch level in accordance with Common
  61. p6d    09 Oct 1993    AS    Updated for CTANGLE.W 2.8. (This was p7)
  62. p7    13 Nov 1992    H2B    Converted to master change file, updated for
  63.                 CTANGLE.W 2.8. [Not released.]
  64. p7.5    29 Nov 1992    H2B    Updated for CTANGLE.W 2.9beta. [Not released.]
  65. p8    08 Dec 1992    H2B    Updated for CTANGLE.W 2.9++ (stuff went into
  66.                 the source file), ANSI bug in <Get a constant>
  67.                 fixed. [Not released.]
  68. p8a    10 Mar 1993    H2B    Restructured for public release.
  69.                 [Not released.]
  70. p8b    14 Apr 1993    H2B    Updated for CTANGLE.W 3.0beta. [Not released.]
  71. p8c    21 Jun 1993    H2B    Updated for final CTANGLE.W 3.0.
  72. p8d    25 Oct 1993    AS    Incorporated into Amiga version 2.8 [p7] and
  73.                 updated to version 3.0.
  74. p8e    04 Nov 1993    AS    New patch level in accordance with COMMON.
  75. p9    18 Nov 1993    AS    Updated to CTANGLE.W 3.1
  76. p9a    30 Nov 1993    AS    Minor changes and corrections.
  77. p9b    06 Dec 1993    AS    Multilinguality implemented.
  78. p9c    18 Jan 1994    AS    Version information included.
  79. p9d    13 May 1994    AS    Dynamic memory allocation.
  80.     02 Jul 1994    AS    Portability version.
  81. ------------------------------------------------------------------------------
  82. @x l.1
  83. % This file is part of CWEB.
  84. % This program by Silvio Levy and Donald E. Knuth
  85. % is based on a program by Knuth.
  86. % It is distributed WITHOUT ANY WARRANTY, express or implied.
  87. % Version 3.1 --- November 1993
  88.  
  89. % Copyright (C) 1987,1990,1993 Silvio Levy and Donald E. Knuth
  90. @y
  91. % This file, CTANGLE.W, is part of CWEB.
  92. % This program by Silvio Levy and Donald E. Knuth
  93. % is based on a program by Knuth.
  94. % It is distributed WITHOUT ANY WARRANTY, express or implied.
  95. % Version 2.4 --- Don Knuth, April 1992
  96. % Version 2.4 [p5] --- Hans-Hermann Bode, July 1992
  97. % Version 2.4 [p5a] --- Klaus Guntermann, July 1992
  98. % Version 2.4 [p5b] --- Hans-Hermann Bode, July 1992
  99. % Version 2.7 --- Don Knuth, July 1992
  100. % Version 2.7 [p6] --- Hans-Hermann Bode, September 1992
  101. % Version 2.7 [p6a] --- Andreas Scherer, March 1993
  102. % Version 2.7 [p6b] --- Andreas Scherer, July 1993
  103. % Version 2.7 [p6c] --- Andreas Scherer, September 1993
  104. % Version 2.8 --- Don Knuth, September 1992
  105. % Version 2.8 [p7] --- Andreas Scherer, October 1993
  106. % Version 3.0 --- Don Knuth, June 1993
  107. % Version 3.0 [p8c] --- Hans-Hermann Bode, June 1993
  108. % Version 3.0 [p8d] --- Andreas Scherer, October 1993
  109. % Version 3.0 [p8e] --- Andreas Scherer, November 1993
  110. % Version 3.1 --- Don Knuth, November 1993
  111. % Version 3.1 [p9] --- Andreas Scherer, November 1993
  112. % Version 3.1 [p9a] --- Andreas Scherer, November 1993
  113. % Version 3.1 [p9b] --- Andreas Scherer, December 1993
  114. % Version 3.1 [p9c] --- Andreas Scherer, January 1994
  115. % Version 3.1 [p9d] --- Andreas Scherer, July 1994
  116.  
  117. % Copyright (C) 1987,1990,1993 Silvio Levy and Donald E. Knuth
  118. % Copyright (C) 1991-1993 Hans-Hermann Bode
  119. % Copyright (C) 1993,1994 Andreas Scherer
  120. @z
  121. ------------------------------------------------------------------------------
  122. @x l.25
  123. \def\title{CTANGLE (Version 3.1)}
  124. @y
  125. \def\title{CTANGLE (Version 3.1 [p9d])}
  126. @z
  127. ------------------------------------------------------------------------------
  128. @x l.29
  129.   \centerline{(Version 3.1)}
  130. @y
  131.   \centerline{(Version 3.1 [p9d])}
  132. @z
  133. ------------------------------------------------------------------------------
  134. @x l.33
  135. Copyright \copyright\ 1987, 1990, 1993 Silvio Levy and Donald E. Knuth
  136. @y
  137. Copyright \copyright\ 1987, 1990, 1993 Silvio Levy and Donald E. Knuth
  138. \smallskip\noindent
  139. Copyright \copyright\ 1991--1993 Hans-Hermann Bode
  140. \smallskip\noindent
  141. Copyright \copyright\ 1993, 1994 Andreas Scherer
  142. @z
  143. ------------------------------------------------------------------------------
  144. Activate this, if only the changed modules should be printed.
  145. x l.46
  146. \let\maybe=\iftrue
  147. y
  148. \let\maybe=\iffalse
  149. z
  150. ------------------------------------------------------------------------------
  151. TRANSLATION
  152. @x l.59
  153. @d banner "This is CTANGLE (Version 3.1)\n"
  154. @y
  155. @d banner get_string(MSG_BANNER_CT1)
  156. @z
  157. ------------------------------------------------------------------------------
  158. ANSI
  159. @x l.69
  160. @ We predeclare several standard system functions here instead of including
  161. their system header files, because the names of the header files are not as
  162. standard as the names of the functions. (For example, some \CEE/ environments
  163. have \.{<string.h>} where others have \.{<strings.h>}.)
  164.  
  165. @<Predecl...@>=
  166. extern int strlen(); /* length of string */
  167. extern int strcmp(); /* compare strings lexicographically */
  168. extern char* strcpy(); /* copy one string to another */
  169. extern int strncmp(); /* compare up to $n$ string characters */
  170. extern char* strncpy(); /* copy up to $n$ string characters */
  171. @y
  172. @ For string handling we include the {\mc ANSI C} system header file instead
  173. of predeclaring the standard system functions |strlen|, |strcmp|, |strcpy|,
  174. |strncmp|, and |strncpy|.
  175. @^system dependencies@>
  176.  
  177. @<Include files@>=
  178. #include <string.h>
  179. @z
  180. ------------------------------------------------------------------------------
  181. ANSI
  182. @x l.89
  183. int main (ac, av)
  184. int ac;
  185. char **av;
  186. @y
  187. int main (int ac, char **av)
  188. @z
  189. ------------------------------------------------------------------------------
  190. MEMORY ALLOCATION
  191. @x l.95
  192.   @<Set initial values@>;
  193.   common_init();
  194. @y
  195.   common_init();
  196.   @<Set initial values@>;
  197. @z
  198. ------------------------------------------------------------------------------
  199. PORTABILITY, SYSTEM DEPENDENCIES
  200. @x l.124
  201. @i common.h
  202. @y
  203. @i comm-p.h
  204. @^system dependencies@>
  205. @z
  206. ------------------------------------------------------------------------------
  207. PORTABILITY
  208. @x l.151
  209.   eight_bits *tok_start; /* pointer into |tok_mem| */
  210. @y
  211.   eight_bits HUGE *tok_start; /* pointer into |tok_mem| */
  212. @z
  213. ------------------------------------------------------------------------------
  214. MEMORY ALLOCATION
  215. @x l.157
  216. text text_info[max_texts];
  217. text_pointer text_info_end=text_info+max_texts-1;
  218. @y
  219. text *text_info;
  220. text_pointer text_info_end;
  221. @z
  222. ------------------------------------------------------------------------------
  223. MEMORY ALLOCATION, PORTABILITY
  224. @x l.160
  225. eight_bits tok_mem[max_toks];
  226. eight_bits *tok_mem_end=tok_mem+max_toks-1;
  227. eight_bits *tok_ptr; /* first unused position in |tok_mem| */
  228. @y
  229. eight_bits HUGE *tok_mem;
  230. eight_bits HUGE *tok_mem_end;
  231. eight_bits HUGE *tok_ptr; /* first unused position in |tok_mem| */
  232. @z
  233. ------------------------------------------------------------------------------
  234. MEMORY ALLOCATION, SYSTEM DEPENDENCIES
  235. @x l.165
  236. text_info->tok_start=tok_ptr=tok_mem;
  237. @y
  238. alloc_object(section_text,longest_name+1,char);
  239. section_text_end = section_text + longest_name;
  240. alloc_object(text_info,max_texts,text);
  241. text_info_end = text_info + max_texts - 1;
  242. #ifdef __TURBOC__
  243. tok_mem=allocsafe(max_toks,sizeof(*tok_mem));
  244. #else
  245. alloc_object(tok_mem,max_toks,eight_bits);
  246. #endif
  247. tok_mem_end = tok_mem + max_toks - 1;
  248. text_info->tok_start=tok_ptr=tok_mem;
  249. alloc_object(stack,stack_size+1,output_state);
  250. stack_end = stack + stack_size;
  251. @^system dependencies@>
  252. @z
  253. ------------------------------------------------------------------------------
  254. PORTABILITY
  255. @x l.175
  256. name_dir->equiv=(char *)text_info; /* the undefined section has no replacement text */
  257. @y
  258. name_dir->equiv=(void HUGE *)text_info; /* the undefined section has no replacement text */
  259. @z
  260. ------------------------------------------------------------------------------
  261. ANSI
  262. @x l.181
  263. int names_match(p,first,l)
  264. name_pointer p; /* points to the proposed match */
  265. char *first; /* position of first character of string */
  266. int l; /* length of identifier */
  267. @y
  268. int names_match(name_pointer p,char *first,int l,eight_bits dummy)
  269. /* |p|: points to the proposed match */
  270. /* |first|: position of first character of string */
  271. /* |l|: length of identifier */
  272. /* |dummy|: not used by \.{TANGLE} */
  273. @z
  274. ------------------------------------------------------------------------------
  275. ANSI
  276. @x l.196
  277. void
  278. init_node(node)
  279. name_pointer node;
  280. @y
  281. void init_node(name_pointer node)
  282. @z
  283. ------------------------------------------------------------------------------
  284. PORTABILITY
  285. @x l.200
  286.     node->equiv=(char *)text_info;
  287. @y
  288.     node->equiv=(void HUGE *)text_info;
  289. @z
  290. ------------------------------------------------------------------------------
  291. ANSI
  292. @x l.202
  293. void
  294. init_p() {}
  295. @y
  296. void init_p(name_pointer dummy1,eight_bits dummy2)
  297. {}
  298. @z
  299. ------------------------------------------------------------------------------
  300. ANSI
  301. @x l.258
  302. void
  303. store_two_bytes(x)
  304. sixteen_bits x;
  305. @y
  306. static void store_two_bytes(sixteen_bits x)
  307. @z
  308. ------------------------------------------------------------------------------
  309. TRANSLATION
  310. @x l.262
  311.   if (tok_ptr+2>tok_mem_end) overflow("token");
  312. @y
  313.   if (tok_ptr+2>tok_mem_end) overflow(get_string(MSG_OVERFLOW_CT26));
  314. @z
  315. ------------------------------------------------------------------------------
  316. PORTABILITY
  317. @x l.295
  318.   eight_bits *end_field; /* ending location of replacement text */
  319.   eight_bits *byte_field; /* present location within replacement text */
  320. @y
  321.   eight_bits HUGE *end_field; /* ending location of replacement text */
  322.   eight_bits HUGE *byte_field; /* present location within replacement text */
  323. @z
  324. ------------------------------------------------------------------------------
  325. MEMORY ALLOCATION
  326. @x l.312
  327. output_state stack[stack_size+1]; /* info for non-current levels */
  328. stack_pointer stack_ptr; /* first unused location in the output state stack */
  329. stack_pointer stack_end=stack+stack_size; /* end of |stack| */
  330. @y
  331. output_state *stack; /* info for non-current levels */
  332. stack_pointer stack_ptr; /* first unused location in the output state stack */
  333. stack_pointer stack_end; /* end of |stack| */
  334. @z
  335. ------------------------------------------------------------------------------
  336. ANSI, TRANSLATION
  337. @x l.334
  338. void
  339. push_level(p) /* suspends the current level */
  340. name_pointer p;
  341. {
  342.   if (stack_ptr==stack_end) overflow("stack");
  343. @y
  344. static void push_level(name_pointer p) /* suspends the current level */
  345. {
  346.   if (stack_ptr==stack_end) overflow(get_string(MSG_OVERFLOW_CT30));
  347. @z
  348. ------------------------------------------------------------------------------
  349. ANSI
  350. @x l.353
  351. void
  352. pop_level(flag) /* do this when |cur_byte| reaches |cur_end| */
  353. int flag; /* |flag==0| means we are in |output_defs| */
  354. @y
  355. static void pop_level(int flag) /* do this when |cur_byte| reaches |cur_end| */
  356. @z
  357. ------------------------------------------------------------------------------
  358. ANSI
  359. @x l.389
  360. void
  361. get_output() /* sends next token to |out_char| */
  362. @y
  363. static void get_output(void) /* sends next token to |out_char| */
  364. @z
  365. ------------------------------------------------------------------------------
  366. PORTABILITY, TRANSLATION
  367. @x l.423
  368.   if ((a+name_dir)->equiv!=(char *)text_info) push_level(a+name_dir);
  369.   else if (a!=0) {
  370.     printf("\n! Not present: <");
  371. @y
  372.   if ((a+name_dir)->equiv!=(void HUGE *)text_info) push_level(a+name_dir);
  373.   else if (a!=0) {
  374.     printf(get_string(MSG_ERROR_CT34));
  375. @z
  376. ------------------------------------------------------------------------------
  377. ANSI
  378. @x l.476
  379. void
  380. flush_buffer() /* writes one line to output file */
  381. @y
  382. static void flush_buffer(void) /* writes one line to output file */
  383. @z
  384. ------------------------------------------------------------------------------
  385. MEMORY ALLOCATION
  386. @x l.497
  387. name_pointer output_files[max_files];
  388. name_pointer *cur_out_file, *end_output_files, *an_output_file;
  389. char cur_section_name_char; /* is it |'<'| or |'('| */
  390. char output_file_name[longest_name]; /* name of the file */
  391.  
  392. @ We make |end_output_files| point just beyond the end of
  393. |output_files|. The stack pointer
  394. |cur_out_file| starts out there. Every time we see a new file, we
  395. decrement |cur_out_file| and then write it in.
  396. @<Set initial...@>=
  397. cur_out_file=end_output_files=output_files+max_files;
  398. @y
  399. name_pointer *output_files;
  400. name_pointer *cur_out_file, *end_output_files, *an_output_file;
  401. char cur_section_name_char; /* is it |'<'| or |'('| */
  402. char *output_file_name; /* name of the file */
  403.  
  404. @ We make |end_output_files| point just beyond the end of
  405. |output_files|. The stack pointer
  406. |cur_out_file| starts out there. Every time we see a new file, we
  407. decrement |cur_out_file| and then write it in.
  408.  
  409. @<Set initial...@>=
  410. alloc_object(output_files,max_files,name_pointer);
  411. alloc_object(output_file_name,longest_name,char);
  412. cur_out_file=end_output_files=output_files+max_files;
  413. @z
  414. ------------------------------------------------------------------------------
  415. TRANSLATION
  416. @x l.519
  417.     overflow("output files");
  418. @y
  419.     overflow(get_string(MSG_OVERFLOW_CT40));
  420. @z
  421. ------------------------------------------------------------------------------
  422. ANSI
  423. @x l.526
  424. @<Predecl...@>=
  425. void phase_two();
  426.  
  427. @ @c
  428. void
  429. phase_two () {
  430. @y
  431. @<Predecl...@>=
  432. static void phase_two(void);
  433.  
  434. @ @c
  435. static void phase_two (void) {
  436. @z
  437. ------------------------------------------------------------------------------
  438. TRANSLATION
  439. @x l.537
  440.     printf("\n! No program text was specified."); mark_harmless;
  441. @y
  442.     printf(get_string(MSG_WARNING_CT42)); mark_harmless;
  443. @z
  444. ------------------------------------------------------------------------------
  445. TRANSLATION
  446. @x l.543
  447.         printf("\nWriting the output file (%s):",C_file_name);
  448. @y
  449.         printf(get_string(MSG_PROGRESS_CT42_1),C_file_name);
  450. @z
  451. ------------------------------------------------------------------------------
  452. TRANSLATION
  453. @x l.547
  454.         printf("\nWriting the output files:");
  455. @y
  456.         printf(get_string(MSG_PROGRESS_CT42_2));
  457. @z
  458. ------------------------------------------------------------------------------
  459. TRANSLATION
  460. @x l.557
  461.     if(show_happiness) printf("\nDone.");
  462. @y
  463.     if(show_happiness) printf(get_string(MSG_PROGRESS_CT42_3));
  464. @z
  465. ------------------------------------------------------------------------------
  466. TRANSLATION
  467. @x l.571
  468.     if (C_file ==0) fatal("! Cannot open output file:",output_file_name);
  469. @y
  470.     if (C_file ==0) fatal(get_string(MSG_FATAL_CO78),output_file_name);
  471. @z
  472. ------------------------------------------------------------------------------
  473. ANSI
  474. @x l.595
  475. @ @<Predecl...@>=
  476. void output_defs();
  477.  
  478. @ @c
  479. void
  480. output_defs()
  481. @y
  482. @ @<Predecl...@>=
  483. static void output_defs(void);
  484.  
  485. @ @c
  486. static void output_defs(void)
  487. @z
  488. ------------------------------------------------------------------------------
  489. TRANSLATION
  490. @x l.623
  491.           else if (a<050000) { confusion("macro defs have strange char");}
  492. @y
  493.           else if (a<050000) { confusion(get_string(MSG_CONFUSION_CT47));}
  494. @z
  495. ------------------------------------------------------------------------------
  496. ANSI, PORTABILITY
  497. @x l.641
  498. @<Predecl...@>=
  499. void out_char();
  500.  
  501. @ @c
  502. void
  503. out_char(cur_char)
  504. eight_bits cur_char;
  505. {
  506.   char *j, *k; /* pointer into |byte_mem| */
  507. @y
  508. @<Predecl...@>=
  509. static void out_char(eight_bits);
  510.  
  511. @ @c
  512. static void out_char(eight_bits cur_char)
  513. {
  514.   char HUGE *j;
  515.   char HUGE *k; /* pointer into |byte_mem| */
  516. @z
  517. ------------------------------------------------------------------------------
  518. MEMORY ALLOCATION
  519. @x l.700
  520. char translit[128][translit_length];
  521.  
  522. @ @<Set init...@>=
  523. {
  524.   int i;
  525.   for (i=0;i<128;i++) sprintf(translit[i],"X%02X",(unsigned)(128+i));
  526. }
  527. @y
  528. char **translit;
  529.  
  530. @ @<Set init...@>=
  531. {
  532.   int i;
  533.   alloc_object(translit,128,char *);
  534.   for(i=0; i<128; i++)
  535.     alloc_object(translit[i],translit_length,char);
  536.   for (i=0;i<128;i++)
  537.     sprintf(translit[i],"X%02X",(unsigned)(128+i));
  538. }
  539. @z
  540. ------------------------------------------------------------------------------
  541. MEMORY ALLOCATION
  542. @x l.776
  543. eight_bits ccode[256]; /* meaning of a char following \.{@@} */
  544.  
  545. @ @<Set ini...@>= {
  546.   int c; /* must be |int| so the |for| loop will end */
  547. @y
  548. eight_bits *ccode; /* meaning of a char following \.{@@} */
  549.  
  550. @ @<Set ini...@>= {
  551.   int c; /* must be |int| so the |for| loop will end */
  552.   alloc_object(ccode,256,eight_bits);
  553. @z
  554. ------------------------------------------------------------------------------
  555. ANSI
  556. @x l.800
  557. eight_bits
  558. skip_ahead() /* skip to next control code */
  559. @y
  560. static eight_bits skip_ahead(void) /* skip to next control code */
  561. @z
  562. ------------------------------------------------------------------------------
  563. @x l.829
  564. No comment, long or short, is allowed to contain `\.{@@ }' or `\.{@@*}'.
  565. @y
  566. No comment, long or short, is allowed to contain `\.{@@\ }' or `\.{@@*}'.
  567. @z
  568. ------------------------------------------------------------------------------
  569. ANSI
  570. @x l.835
  571. int skip_comment(is_long_comment) /* skips over comments */
  572. boolean is_long_comment;
  573. @y
  574. static int skip_comment(boolean is_long_comment) /* skips over comments */
  575. @z
  576. ------------------------------------------------------------------------------
  577. TRANSLATION
  578. @x l.844
  579.           err_print("! Input ended in mid-comment");
  580. @y
  581.           err_print(get_string(MSG_ERROR_CT60_1));
  582. @z
  583. ------------------------------------------------------------------------------
  584. TRANSLATION
  585. @x l.857
  586.         err_print("! Section name ended in mid-comment"); loc--;
  587. @y
  588.         err_print(get_string(MSG_ERROR_CT60_2)); loc--;
  589. @z
  590. ------------------------------------------------------------------------------
  591. ANSI
  592. @x l.885
  593. eight_bits
  594. get_next() /* produces the next input token */
  595. @y
  596. static eight_bits get_next(void) /* produces the next input token */
  597. @z
  598. ------------------------------------------------------------------------------
  599. TRANSLATION
  600. @x l.1003
  601.         err_print("! String didn't end"); loc=limit; break;
  602. @y
  603.         err_print(get_string(MSG_ERROR_CT67_1)); loc=limit; break;
  604. @z
  605. ------------------------------------------------------------------------------
  606. TRANSLATION
  607. @x l.1007
  608.         err_print("! Input ended in middle of string"); loc=buffer; break;
  609. @y
  610.         err_print(get_string(MSG_ERROR_CT67_2)); loc=buffer; break;
  611. @z
  612. ------------------------------------------------------------------------------
  613. TRANSLATION
  614. @x l.1025
  615.     printf("\n! String too long: ");
  616. @y
  617.     printf(get_string(MSG_ERROR_CT67_3));
  618. @z
  619. ------------------------------------------------------------------------------
  620. TRANSLATION
  621. @x l.1042
  622.     case translit_code: err_print("! Use @@l in limbo only"); continue;
  623. @y
  624.     case translit_code: err_print(get_string(MSG_ERROR_CT68_1)); continue;
  625. @z
  626. ------------------------------------------------------------------------------
  627. TRANSLATION
  628. @x l.1047
  629.         err_print("! Double @@ should be used in control text");
  630. @y
  631.         err_print(get_string(MSG_ERROR_CT68_2));
  632. @z
  633. ------------------------------------------------------------------------------
  634. TRANSLATION
  635. @x l.1073
  636.         err_print("! Double @@ should be used in ASCII constant");
  637. @y
  638.         err_print(get_string(MSG_ERROR_CT69));
  639. @z
  640. ------------------------------------------------------------------------------
  641. TRANSLATION
  642. @x l.1079
  643.         err_print("! String didn't end"); loc=limit-1; break;
  644. @y
  645.         err_print(get_string(MSG_ERROR_CT67_1)); loc=limit-1; break;
  646. @z
  647. ------------------------------------------------------------------------------
  648. TRANSLATION
  649. @x l.1110
  650.     err_print("! Input ended in section name");
  651. @y
  652.     err_print(get_string(MSG_ERROR_CT72_1));
  653. @z
  654. ------------------------------------------------------------------------------
  655. TRANSLATION
  656. @x l.1123
  657.   printf("\n! Section name too long: ");
  658. @y
  659.   printf(get_string(MSG_ERROR_CT72_2));
  660. @z
  661. ------------------------------------------------------------------------------
  662. TRANSLATION
  663. @x l.1137
  664.     err_print("! Section name didn't end"); break;
  665. @y
  666.     err_print(get_string(MSG_ERROR_CT73_1)); break;
  667. @z
  668. ------------------------------------------------------------------------------
  669. TRANSLATION
  670. @x l.1141
  671.     err_print("! Nesting of section names not allowed"); break;
  672. @y
  673.     err_print(get_string(MSG_ERROR_CT73_2)); break;
  674. @z
  675. ------------------------------------------------------------------------------
  676. TRANSLATION
  677. @x l.1155
  678.   if (loc>=limit) err_print("! Verbatim string didn't end");
  679. @y
  680.   if (loc>=limit) err_print(get_string(MSG_ERROR_CT74));
  681. @z
  682. ------------------------------------------------------------------------------
  683. TRANSLATION
  684. @x l.1178
  685. @d app_repl(c)  {if (tok_ptr==tok_mem_end) overflow("token"); *tok_ptr++=c;}
  686. @y
  687. @d app_repl(c)
  688.   {if (tok_ptr==tok_mem_end)
  689.      overflow(get_string(MSG_OVERFLOW_CT26));
  690.    *tok_ptr++=c;}
  691. @z
  692. ------------------------------------------------------------------------------
  693. ANSI
  694. @x l.1185
  695. void
  696. scan_repl(t) /* creates a replacement text */
  697. eight_bits t;
  698. @y
  699. static void scan_repl(eight_bits t) /* creates a replacement text */
  700. @z
  701. ------------------------------------------------------------------------------
  702. ANSI
  703. @x l.1196
  704.       default: app_repl(a); /* store |a| in |tok_mem| */
  705. @y
  706.       case ')': /* some compilers complain about `missing space between
  707.          macro name and its replacement list', because {\mc ANSI C} requires
  708.          a space after the closing parenthesis */
  709.          app_repl(a); if(t==macro) app_repl(' '); break;
  710.       default: app_repl(a); /* store |a| in |tok_mem| */
  711. @z
  712. ------------------------------------------------------------------------------
  713. TRANSLATION
  714. @x l.1199
  715.   if (text_ptr>text_info_end) overflow("text");
  716. @y
  717.   if (text_ptr>text_info_end) overflow(get_string(MSG_OVERFLOW_CT76));
  718. @z
  719. ------------------------------------------------------------------------------
  720. ANSI
  721. @x l.1214
  722. {int a=id_lookup(id_first,id_loc)-name_dir; app_repl((a / 0400)+0200);
  723. @y
  724. {int a=id_lookup(id_first,id_loc,' ')-name_dir; app_repl((a / 0400)+0200);
  725. @z
  726. ------------------------------------------------------------------------------
  727. ANSI
  728. @x l.1218
  729. case identifier: a=id_lookup(id_first,id_loc)-name_dir;
  730. @y
  731. case identifier: a=id_lookup(id_first,id_loc,' ')-name_dir;
  732. @z
  733. ------------------------------------------------------------------------------
  734. TRANSLATION
  735. @x l.1240
  736.     err_print("! @@d, @@f and @@c are ignored in C text"); continue;
  737. @y
  738.     err_print(get_string(MSG_ERROR_CT78)); continue;
  739. @z
  740. ------------------------------------------------------------------------------
  741. TRANSLATION
  742. @x l.1250
  743.   if (*try_loc=='=') err_print ("! Missing `@@ ' before a named section");
  744. @y
  745.   if (*try_loc=='=') err_print (get_string(MSG_ERROR_CT79));
  746. @z
  747. ------------------------------------------------------------------------------
  748. TRANSLATION
  749. @x l.1261
  750.       else err_print("! Double @@ should be used in string");
  751. @y
  752.       else err_print(get_string(MSG_ERROR_CT80));
  753. @z
  754. ------------------------------------------------------------------------------
  755. TRANSLATION
  756. @x l.1308
  757.     default: err_print("! Unrecognized escape sequence");
  758. @y
  759.     default: err_print(get_string(MSG_ERROR_CT81));
  760. @z
  761. ------------------------------------------------------------------------------
  762. ANSI
  763. @x l.1335
  764. void
  765. scan_section()
  766. @y
  767. static void scan_section(void)
  768. @z
  769. ------------------------------------------------------------------------------
  770. TRANSLATION
  771. @x l.1382
  772.     err_print("! Definition flushed, must start with identifier");
  773. @y
  774.     err_print(get_string(MSG_ERROR_CT85));
  775. @z
  776. ------------------------------------------------------------------------------
  777. ANSI
  778. @x l.1386
  779.   app_repl(((a=id_lookup(id_first,id_loc)-name_dir) / 0400)+0200);
  780. @y
  781.   app_repl(((a=id_lookup(id_first,id_loc,' ')-name_dir) / 0400)+0200);
  782. @z
  783. ------------------------------------------------------------------------------
  784. PORTABILITY
  785. @x l.1422
  786. else if (p->equiv==(char *)text_info) p->equiv=(char *)cur_text;
  787. @y
  788. else if (p->equiv==(void HUGE *)text_info) p->equiv=(void HUGE *)cur_text;
  789. @z
  790. ------------------------------------------------------------------------------
  791. ANSI
  792. @x l.1433
  793. @ @<Predec...@>=
  794. void phase_one();
  795.  
  796. @ @c
  797. void
  798. phase_one() {
  799. @y
  800. @ @<Predec...@>=
  801. static void phase_one(void);
  802.  
  803. @ @c
  804. static void phase_one(void) {
  805. @z
  806. ------------------------------------------------------------------------------
  807. ANSI
  808. @x l.1451
  809. @<Predecl...@>=
  810. void skip_limbo();
  811.  
  812. @ @c
  813. void
  814. skip_limbo()
  815. @y
  816. @<Predecl...@>=
  817. static void skip_limbo(void);
  818.  
  819. @ @c
  820. static void skip_limbo(void)
  821. @z
  822. ------------------------------------------------------------------------------
  823. TRANSLATION
  824. @x l.1472
  825.             err_print("! Double @@ should be used in control text");
  826. @y
  827.             err_print(get_string(MSG_ERROR_CT68_2));
  828. @z
  829. ------------------------------------------------------------------------------
  830. TRANSLATION
  831. @x l.1476
  832.         default: err_print("! Double @@ should be used in limbo");
  833. @y
  834.         default: err_print(get_string(MSG_ERROR_CT93));
  835. @z
  836. ------------------------------------------------------------------------------
  837. TRANSLATION
  838. @x l.1488
  839.     err_print("! Improper hex number following @@l");
  840. @y
  841.     err_print(get_string(MSG_ERROR_CT94_1));
  842. @z
  843. ------------------------------------------------------------------------------
  844. TRANSLATION
  845. @x l.1498
  846.       err_print("! Replacement string in @@l too long");
  847. @y
  848.       err_print(get_string(MSG_ERROR_CT94_2));
  849. @z
  850. ------------------------------------------------------------------------------
  851. ANSI
  852. @x l.1501
  853.       strncpy(translit[i-0200],beg,loc-beg);
  854. @y
  855.       strncpy(translit[i-0200],beg,(size_t)(loc-beg));
  856. @z
  857. ------------------------------------------------------------------------------
  858. ANSI, TRANSLATION
  859. @x l.1506
  860. @ Because on some systems the difference between two pointers is a |long|
  861. but not an |int|, we use \.{\%ld} to print these quantities.
  862.  
  863. @c
  864. void
  865. print_stats() {
  866.   printf("\nMemory usage statistics:\n");
  867.   printf("%ld names (out of %ld)\n",
  868.           (long)(name_ptr-name_dir),(long)max_names);
  869.   printf("%ld replacement texts (out of %ld)\n",
  870.           (long)(text_ptr-text_info),(long)max_texts);
  871.   printf("%ld bytes (out of %ld)\n",
  872.           (long)(byte_ptr-byte_mem),(long)max_bytes);
  873.   printf("%ld tokens (out of %ld)\n",
  874.           (long)(tok_ptr-tok_mem),(long)max_toks);
  875. }
  876. @y
  877. @ {\mc ANSI C} declares the difference between two pointers to be of type
  878. |ptrdiff_t| which equals |long| on (almost) all systems instead of |int|,
  879. so we use \.{\%ld} to print these quantities and cast them to |long|
  880. explicitly.
  881.  
  882. @c
  883. void print_stats(void) {
  884.   printf(get_string(MSG_STATS_CT95_1));
  885.   printf(get_string(MSG_STATS_CT95_2),
  886.           (long)(name_ptr-name_dir),(long)max_names);
  887.   printf(get_string(MSG_STATS_CT95_3),
  888.           (long)(text_ptr-text_info),(long)max_texts);
  889.   printf(get_string(MSG_STATS_CT95_4),
  890.           (long)(byte_ptr-byte_mem),(long)max_bytes);
  891.   printf(get_string(MSG_STATS_CT95_5),
  892.           (long)(tok_ptr-tok_mem),(long)max_toks);
  893. }
  894. @z
  895. ------------------------------------------------------------------------------
  896. ANSI, SYSTEM DEPENDENCIES
  897. @x l.1523
  898. @** Index.
  899. @y
  900. @** Function declarations.  Here are declarations---conforming to
  901. {\mc ANSI~C}---of all functions in this code, as far as they are
  902. not already in |"common.h"|.  These are private to \.{CTANGLE}.
  903.  
  904. @<Predecl...@>=
  905. static eight_bits get_next(void);@/
  906. static eight_bits skip_ahead(void);@/
  907. static int skip_comment(boolean);@/
  908. static void flush_buffer(void);@/
  909. static void get_output(void);@/
  910. static void pop_level(int);@/
  911. static void push_level(name_pointer);@/
  912. static void scan_repl(eight_bits);@/
  913. static void scan_section(void);@/
  914. static void store_two_bytes(sixteen_bits);
  915.  
  916. @* Version information.  The {\mc AMIGA} operating system provides the
  917. `version' command and good programs answer with some informations about
  918. their creation date and their current version.
  919. @^system dependencies@>
  920.  
  921. @<Glob...@>=
  922. #ifdef _AMIGA
  923. const unsigned char *Version = "$VER: CTangle 3.1 [p9d] "__AMIGADATE__;
  924. #endif
  925.  
  926. @** Index.
  927. @z
  928. ------------------------------------------------------------------------------
  929.